﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace xiketang.com.LotteryPro
{
    /// <summary>
    /// 选号器
    /// </summary>
    public class Selector
    {
        //红色球池
        public List<string> RedNumberList { get; set; }

        //蓝色球池
        public List<string> BlueNumberList { get; set; }
        
        //存储选择后的号码
        public List<DoubleChromosphere> SelectedNums { get; set; } = new List<DoubleChromosphere>();

        //私有化随机数
        private Random random = new Random();


        /// <summary>
        /// 构造方法：初始化红蓝球池
        /// </summary>
        public Selector() 
        {
            RedNumberList = new List<string>
            {
                "01","02","03","04","05","06","07","08","09","10",
                "11","12","13","14","15","16","17","18","19","20",
                "21","22","23","24","25","26","27","28","29","30",
                "31","32","33"
            };
            BlueNumberList = new List<string>
            {
                "01","02","03","04","05","06","07","08","09","10",
                "11","12","13","14","15","16"
            };
        }

        public List<string> CreateRandomNum()
        {
            List<string> numList = new List<string>();
            //生成6个红球
            while (true)
            {
                if (numList.Count == 6) break; //选取了6个数字后，退出循环
                string num = RedNumberList[random.Next(33)];
                if (numList.Contains(num)) continue;
                else
                {
                    numList.Add(num);
                }
            }
            //生成1个蓝球
            numList.Add(BlueNumberList[random.Next(16)]);
            return numList;
        }

    }
}
